package com.weijian.dal.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 政策分类枚举值
 */
@Getter
public enum CategoryEnum {

    MONETARY("货币", 0),
    BANK("银行", 1),
    TRUST("信托", 2),
    INSURANCE("保险", 3),
    SECURITY("证券", 4),
    OTHER("其他", 5);

    private final String  text;
    private final Integer value;

    CategoryEnum(String text, int value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 根据 value 获取枚举
     */
    public static CategoryEnum getEnumByValue(Integer value) {
        for (CategoryEnum item : values()) {
            if (Objects.equals(item.value, value)) {
                return item;
            }
        }
        return null;
    }

    /**
     * 根据 value 获取枚举 text
     */
    public static String getTextByValue(Integer value) {
        for (CategoryEnum item : values()) {
            if (Objects.equals(item.value, value)) {
                return item.text;
            }
        }
        return null;
    }

}

